package com.su02.multi.chainrule;

import java.util.Map;

/**
 * f(x0, x1, ..., xn) = C
 */
public class Constant extends Function {
    private final double constant;

    public Constant(double constant) {
        this.constant = constant;
    }

    @Override
    public Function backward(int id) {
        return new Constant(0);
    }

    @Override
    protected Function doBackward(int id) {
        return new Constant(0);
    }

    @Override
    public double forward(Map<Integer, Double> vector) {
        return constant;
    }

    double getConstant() {
        return this.constant;
    }
}
